<template lang="">
    <div>
            
     <van-form>
       <van-field v-model='form.mobile' label='手机号' placeholder='手机号' :rules="[{'required':true,'message':'必须输入手机号'}]"/>
       <van-button @click='send'>发送</van-button>
        <van-field v-model='form.password' placeholder='密码'/>
        <van-field v-model='form.repassword' placeholder='确认密码'/>
        <van-field v-model='form.code' placeholder='验证码'/>
        <van-button @click='reg'>注册</van-button>
    </van-form>
    </div>
</template>
<script>
export default {
    data(){
        return{
            form:{},
            username:'',
            password:''
        }
    },
    methods: {
        //发送验证码
        send(){
            //正则验证手机号
            let reg=/^1[3-9]\d{9}$/
            if(!reg.test(this.form.mobile)){
                alert('手机号不合法')
                return
            }
            //调用接口发送验证码
            this.$axios.get('smscode?mobile='+this.form.mobile).then(res=>{
                alert('发送成功')
                alert(res.data.scode)
            })
        },
        //注册
        reg(){

        }
    },
}
</script>
<style lang="">
    
</style>